<?php
/**
 * Abstract.php
 *
 * @category    Madoqua
 * @package     Db
 * @subpackage  Table
 */

/** base class */
require_once 'Zend/Db/Table.php';

/**
 * Madoqua_Db_Table_Abstract
 *
 * @category    Madoqua
 * @package     Db
 * @subpackage  Table
 */
abstract class Madoqua_Db_Table_Abstract extends Zend_Db_Table_Abstract
{
    /**
     * prefix for tables
     *
     * @var string
     */
    protected $_prefix = '';
    
    /**
     * constructor
     *
     * @param array $config
     */
    public function __construct($config = array())
    {
        if (empty(self::$_defaultDb)) {
            self::$_defaultDb == Madoqua_Application::getDatabase();
            //set up default adapter for ZDT
        }
        
        $this->_prefix = Madoqua_Application::getConfiguration()->database->prefix;
        //table prefix
        
        if (!empty($this->_name)) {
            $this->_name = $this->_prefix . $this->_name; 
        }
        //add prefix to name
        
        if (!empty($config['name'])) {
            $config['name'] = $this->_prefix . $config['name'];
        }
        //add prefix to name param in configuration
        
        parent::__construct($config);
    }
}
